package com.huluspace.filetransfer.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

  /**
   * 添加静态资源处理器，用于处理文件资源的访问
   * @param registry 资源处理器注册器，用于配置资源映射规则
   */
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    // 将/files/**路径的请求映射到本地D:/files/目录下的文件资源
    registry.addResourceHandler("/files/**")
        .addResourceLocations("file:/D:/files/");
  }

}

